package com.felix.pattern.share;

import lombok.extern.slf4j.Slf4j;

/**
 * Demo
 *
 * @author xuejinhua
 * @date 2019/1/24 10:15
 */
@Slf4j
public class Demo {

    public void share(AbstractShareItem item, ShareListener listener) {
        if (item == null) {
            if (listener != null) {
                listener.onCallbak(ShareListener.STATE_FAILURE, "ShareItem 不能为 null");
            }
            return;
        }
        if (listener == null) {
            listener = (state, msg) -> log.info("DEBUG", "ShareListener is null");
        }
        shareImpl(item, listener);
    }

    private void shareImpl(AbstractShareItem item, ShareListener listener) {
        item.doShare(listener);
    }
}
